package drinkkiosk.drinks;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.IOException;
import java.util.LinkedList;
import java.util.logging.Level;
import java.util.logging.Logger;


/**This class represents the database serialization of the Drinks that have been 
 * ordered by the Patrons. The Drink will be retrieved along with the Name,
 * Description, and Picture of the Drink
 * 
 * @author gmcclain2
 */
public class DrinkDatabase{
	/** */
	private LinkedList<SpecialDrink> specialsList= new LinkedList();
	/** */
	private FileOutputStream fOut;
	/** */
	private FileInputStream fIn;
	/** */
	private BufferedOutputStream bOut;
	/** */
	private BufferedInputStream bIn;
	/** */
	private ObjectOutputStream oOut;
	/** */
	private ObjectInputStream oIn;

	/**
	 * 
	 * @return
	 */
	public LinkedList<SpecialDrink> getSpecialsList() {
		return specialsList;
	}

	/**
	 * 
	 * @param specialsList
	 */
	public void setSpecialsList(LinkedList<SpecialDrink> specialsList) {
		this.specialsList = specialsList;
	}
	/**
	 * 
	 */
	public DrinkDatabase(){
	}
	/**
	 * 
	 */
	public void loadSpecialsList(){
		try {
			fIn = new FileInputStream("specials.data");
			bIn = new BufferedInputStream(fIn);
			oIn = new ObjectInputStream(bIn);
			specialsList = (LinkedList<SpecialDrink>) oIn.readObject();
			oIn.close();
			fIn.close();
		} catch (IOException ex) {
			Logger.getLogger(DrinkDatabase.class.getName()).log(Level.SEVERE, null, ex);
		} catch (ClassNotFoundException ex) {
			Logger.getLogger(DrinkDatabase.class.getName()).log(Level.SEVERE, null, ex);
		}
	}
	/**
	 * 
	 */
	public void saveSpecialsList(){
		try {
			fOut = new FileOutputStream("specials.data");
			bOut = new BufferedOutputStream(fOut);
			oOut = new ObjectOutputStream(bOut);
			oOut.writeObject(specialsList);
			oOut.close();
			fOut.close();
		} catch (IOException ex) {
			Logger.getLogger(DrinkDatabase.class.getName()).log(Level.SEVERE, null, ex);
		}
	}

/**This method will be responsible for reading and writing object files in and 
 * out of the input streams in order to get the correct Drink Name, Description,
 * and Picture.
 * 
 * @param Name
 * @param Description
 * @param Picture
 */
public void findSpecialDrink(String Name, String Description, File Picture) {

}
}